class EventEmitter {
  constructor() {
    this.events = {};
  }
  on(event, cb) {
    if (this.events[event] === undefined) {
      this.events[event] = [];
    }
    this.events[event].push(cb);
    return this;
  }
  Off(event) {
    this.events[event] = undefined;
    return this;
  }
  emit(event, ...args) {
    for (let eve of this.events[event]) {
      eve(...args);
    }
    return this;
  }
}

let eventBus = new EventEmitter();
eventBus.on("a", (a = 1) => {
  console.log("成功1！！", a);
});
eventBus.on("b", () => {
  console.log("成功3！！");
});
eventBus.on("a", (a = 2) => {
  console.log("成功2！！", a);
});
console.log(eventBus.events);
eventBus.emit("a", 4);
eventBus.emit("b");
eventBus.Off("a");
